package com.jhhc.WaterQuality.BaseInfo.service.impl;

import com.jhhc.WaterQuality.BaseInfo.entity.BDMS_BA_BASINSCHEME_B;
import com.jhhc.WaterQuality.BaseInfo.dao.BDMS_BA_BASINSCHEME_BMapper;
import com.jhhc.WaterQuality.BaseInfo.service.BDMS_BA_BASINSCHEME_BService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (BdmsBaBasinschemeB)表服务实现类
 *
 * @author makejava
 * @since 2023-07-16 13:08:28
 */
@Service("bdmsBaBasinschemeBService")
public class BDMS_BA_BASINSCHEME_BServiceImpl implements BDMS_BA_BASINSCHEME_BService {
    @Resource
    private BDMS_BA_BASINSCHEME_BMapper bdmsBaBasinschemeBDao;

    /**
     * 通过ID查询单条数据
     *
     * @param pid 主键
     * @return 实例对象
     */
    @Override
    public List<BDMS_BA_BASINSCHEME_B> queryById(Integer pid) {
        return this.bdmsBaBasinschemeBDao.queryById(pid);
    }

    /**
     * 分页查询
     *
     * @param bdmsBaBasinschemeB 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<BDMS_BA_BASINSCHEME_B> queryByPage(BDMS_BA_BASINSCHEME_B bdmsBaBasinschemeB, PageRequest pageRequest) {
        long total = this.bdmsBaBasinschemeBDao.count(bdmsBaBasinschemeB);
        return new PageImpl<>(this.bdmsBaBasinschemeBDao.queryAllByLimit(bdmsBaBasinschemeB, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param bdmsBaBasinschemeB 实例对象
     * @return 实例对象
     */
    @Override
    public BDMS_BA_BASINSCHEME_B insert(BDMS_BA_BASINSCHEME_B bdmsBaBasinschemeB) {
        this.bdmsBaBasinschemeBDao.insert(bdmsBaBasinschemeB);
        return bdmsBaBasinschemeB;
    }

    /**
     * 修改数据
     *
     * @param bdmsBaBasinschemeB 实例对象
     * @return 实例对象
     */
    @Override
    public BDMS_BA_BASINSCHEME_B update(BDMS_BA_BASINSCHEME_B bdmsBaBasinschemeB) {

        return null;
    }

    /**
     * 通过主键删除数据
     *
     * @param pid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer pid) {
        return this.bdmsBaBasinschemeBDao.deleteById(pid) > 0;
    }
}
